package com.potato369.cryptEureka.controller;

import com.potato369.cryptEureka.common.api.CommonResult;
import com.potato369.cryptEureka.service.MemberService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 会员登录注册管理Controller
 * Created by macro on 2018/8/3.
 */
@Api(tags = "UmsMemberController", description = "前端会员管理")
@RestController
@RequestMapping("/sso")
public class UmsMemberController {

    private MemberService memberService;

    @Autowired
    public void setMemberService(MemberService memberService) {
        this.memberService = memberService;
    }

    @ApiOperation("获取验证码")
    @GetMapping(value = "/getAuthCode")
    public CommonResult<?> getAuthCode(@RequestParam String telephone) {
        return this.memberService.generateAuthCode(telephone);
    }

    @ApiOperation("判断验证码是否正确")
    @PostMapping(value = "/verifyAuthCode")
    public CommonResult<?> updatePassword(@RequestParam String telephone,
                                       @RequestParam String authCode) {
        return this.memberService.verifyAuthCode(telephone, authCode);
    }
}
